<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<#include "/common/resources.ftl"/>
<script type="text/javascript">
	$(function(){
		window.m_datagrid = $('#m_datagrid').datagrid({
			url:'${ctx}/qfbao/product/list',
			onLoadSuccess:yixun.closeProgress,
			onBeforeLoad:yixun.progress,
			queryParams:$('#load_list_search').serializeObject(),
			loadMsg:null,
			singleSelect:true,
			fitColumns:true,
			rownumbers:true,
			pagination:true,
			border:'false',
			toolbar:'#m_toolbar'
		});
	
		//按条件查询用户
		window.searchData = function () {
			m_datagrid.datagrid('load',$('#load_list_search').serializeObject());
		}
		
		//删除
		window.deleteDate = function(mid){
			$.messager.confirm('确认!','你确定要删除此数据吗?',function(res){
				if(res){
					$.post("${ctx}/qfbao/product/del",{'id':mid},function(result){
						if (result.errorMsg){
							$.messager.show({
								title: '友情提示',
								msg: 'result.errorMsg'
							});
							m_datagrid.datagrid('reload');
						} else {
							$.messager.show({
								title: '友情提示',
								msg: '删除成功'
							});
						}
					},'json');
				}
			});
		}
		$("#province").combobox({
		onChange: function (n,o) {
			      var val = n;
			      cityId.combobox({
                        disabled: false,
                        url: '${ctx}/qfbao/product/findCity?id=' + n,
                        valueField: 'id',
                        textField: 'name'
                    }).combobox('clear');
		}});
		var cityId = $('#cityId').combobox({
                disabled: true,
                valueField: 'id',
                textField: 'fullName'
            });
	});
	mShowButton = function (value,row,index){
		var btns = [];
		if(row.status=='1'){
		    btns.push('<button class="green_btn" onclick="upAndDown('+value+',0)">下架</button>');
		}else if(row.status=='0'){
		    btns.push('<button class="green_btn" onclick="upAndDown('+value+',1)">上架</button>');
		}
		btns.push('<button class="green_btn" onclick="javascript:window.location.href=\'view?id='+value+'\';void(0);">编辑</button>');
		return btns.join('');
	}
	returnPlat = function (value,row,index){
			if(value=='1'){
				return "是";
			}else {
				return "否";
			}
	}
	
		//上下架
	function upAndDown(id,status){
	    var tip="确定要执行下架操作?";
	    if(status=="1"){
	      tip="确定要执行上架操作?";
	    }
		$.messager.confirm('确认!',tip,function(res){
			if(res){
				$.post("${ctx}/qfbao/product/upAndDown",{'id':id,'status':status},function(result){
					if (result.success=="1"){
						$.messager.show({
							title: '友情提示',
							msg: '操作失败'
						});
					} else if(result.success=="0"){
						$.messager.show({
							title: '友情提示',
							msg: '操作成功'
						});
						m_datagrid.datagrid('reload');
					}
				},'json');
			}
		});
	}
</script>
</head>
<body style="background-color:white;">

<div id="m_toolbar" class="datagrid-toolbar" style="overflow: hidden;height: auto;margin: 15px 0px;background-color: white;border-bottom: none;" border="false">
  <form id="load_list_search" onsubmit="return false;">
  <div class="fm_sty" style="margin: 20px 0px 0px;">
   	<div class="ipt_line">
	<span class="ipt_title">产品名称</span>
		<input type="text" name="name" class="ipt_226" />
	</div>
   	<div class="ipt_line">
	<span class="ipt_title">所属公司</span>
		<select name="companyId" class="easyui-combobox" style="height:39px; width:263px;">
			<option value="">--请选择--</option>
			<#list infos as p>
				<option value="${p.id}">${p.companyName}</option>
			</#list>
		</select>
	</div>
   	<div class="ipt_line">
   	<span class="ipt_title">所属省份</span>
		<!--<select name="province" id="province">
		<option value="">--请选择--</option>
		<#list province as p>
			<option value="${p.id}">${p.name}</option>
		</#list>
		</select>-->
		<input name="province" id="province" class="easyui-combobox" style="height:39px; width:263px;"
			data-options="
				valueField:'id',
				textField:'fullName',
				url:'${ctx}/qfbao/product/findProvince'" />
	</div>
	<div class="ipt_line">
	<span class="ipt_title">所属城市</span>
	<!--	<input type="text" name="cityId" class="ipt_226" />-->
		<!--<select name="cityId" id="cityId">
			<option value=''>--请选择--</option>
		</select>-->
		<input name="cityId" id="cityId" class="easyui-combobox" style="height:39px; width:263px;" />
	</div>
   	<div class="ipt_line">
	<span class="ipt_title">产品类型</span>
	<!--	<input type="text" name="productType" class="ipt_226" />-->
		<select name="productType" class="easyui-combobox" style="height:39px; width:263px;">
			<option value="">--请选择--</option>
			<#list products as p>
				<option value="${p.id}">${p.dicName}</option>
			</#list>
		</select>
	</div>
	<div class="ipt_line_long">
        <button class="red_100" onclick="javascript:window.location.href='view';void(0)">新增</button>
        <button class="red_100" onclick="searchData()">查询</button>
	</div>    
  </div>
  </form>
</div>

<!-- 查找结果 -->
<table style="margin:0px 20px;" id="m_datagrid">
	<thead>
		<tr>
			<th field="name" width="60" height="40" >产品名称</th>
			<th field="companyName" width="60" height="40" >公司</th>
			<!--<th data-options="field:'province'"  width="60" height="40" >省份</th>-->
			<th field="cityName" width="60" height="40" >城市</th>
			<th field="repaymentName" width="60" height="40" >还款方式</th>
			<th field="productName" width="60" height="40" >产品类型</th>
			<!--<th field="maxCredits" width="60" height="40" >最高额度</th>-->
			<!--<th data-options="field:'estimateZg',formatter:function(value,row,index){var key = 'product_estimate_zg';return yixun.combobox_formatter(value,row,index,key);}" width="60" height="40" >预估资格</th>-->
			<!--<th field='estimateDkbl'  width="60" height="40" >预估贷款比例％</th>-->
			<!--<th field="dkServiceFees" width="60" height="40" >贷款公司服务费比例</th>-->
			<!--<th field="showCN" width="60" height="40" >平台手续费％</th>-->
			<!--<th data-options="field:'byPlatform',formatter:returnPlat" width="60" height="40" >贷款是否通过巧房发放</th>-->
			<!--<th field="platformSubCommission" width="60" height="40" >平台分佣比例</th>-->
			<!--<th field="agencySubCommission" width="60" height="40" >中介公司分佣比例</th>-->
			<th field="createTime" width="60" height="40" >创建时间</th>
			<!--<th field="updateTime" width="60" height="40" >修改时间</th>-->
			<th data-options="field:'id',formatter:mShowButton,align:'center'" width="150">操作</th>
		</tr>
	</thead>
</table>

</body>
</html>
